# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jason Chu <jason@archlinux.org>

pkgname=speex
pkgver=1.2.1
pkgrel=1
pkgdesc="A free codec for free speech"
url="https://www.speex.org/"
arch=(loong64 x86_64)
license=(BSD)
depends=(gcc-libs libogg speexdsp)
makedepends=(git)
options=(debug)
_commit=5dceaaf3e23ee7fd17c80cb5f02a838fd6c18e01  # tags/Speex-1.2.1^0
source=("git+https://gitlab.xiph.org/xiph/speex.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd speex
  git describe --tags | sed 's/^Speex-//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd speex
  ./autogen.sh
}

build() {
  cd speex
  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
    --enable-binaries \
    --disable-static
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd speex
  make -k check
}

package() {
  depends+=(libogg.so libspeexdsp.so)
  provides+=(libspeex.so)

  cd speex
  make DESTDIR="$pkgdir" install
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING
}
